< previous page page_267 next page >

Page 267
note.gif Another difference is that the ImageCombo control supports only one style of combo box: the drop-down list. As you may recall, a standard ComboBox control has several other styles available. square.gif

sarrow.gifSee "The Combo Box," p. 75
Setting Up an ImageCombo Box
Like many of the other Windows Common controls, an ImageCombo uses an ImageList control to store the pictures to be displayed in the combo box. For each Item in the ImageCombo's ComboItems collection, you can actually specify the index of these two images:
ImageSet this property to the index of the image that you want to appear to the left of each item.
SelImageThis property is optional. If you supply a value for this property, the image beside an item changes when the item is selected or highlighted with the mouse. If you do not supply a value for the SelImage property, the control uses the image from the Image property.
To learn how users interact with the two types of images, follow these steps:
1. Start a new Standard EXE project, and add an ImageList control.
2. Set the size of the images in the list to 16×16, and insert two pictures. For the example, I used a smiley face and an arrow.
3. Add an ImageCombo control to the form, and add the following code to the form's Load event:
    ImageCombo1.ImageList = ImageList1
    ImageCombo1.ComboItems.Add , , "Moe", 1, 2
    ImageCombo1.ComboItems.Add , , "Larry", 1, 2
    ImageCombo1.ComboItems.Add , , "Curly", 1, 2
    ImageCombo1.ComboItems.Add , , "Shemp", 1, 2
    ImageCombo1.ComboItems.Add , , "Joe", 1, 2
Notice that the Add statements use the same Image and SelImage image indexes for each item.
4. Run the program, and drag the mouse pointer over each item the item list. As you highlight an item, the image should change. In addition, if you have an item selected, the image represented by SelItem is displayed beside both the selected item and the highlighted item, as shown in Figure 12.17.
0267-01.jpg
Figure 12.17
You can use the 
SelImage property to set
apart the highlighted and selected items.

 
< previous page page_267 next page >